package cn.b.training.baby_education_training.repository;

import cn.b.training.baby_education_training.entity.FoodMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @program: baby_education
 * @description
 * @author: wuying
 * @create: 2022-11-29 10:26
 **/
@Repository
public interface FoodMenuRepository extends JpaRepository<FoodMenu,Long> {
    @Query("select a from FoodMenu a where a.id=?1")
    FoodMenu getFoodMenuById(Long id);

    @Query("select a from FoodMenu a where a.foodTitle LIKE CONCAT('%',?1,'%') ")
    List<FoodMenu> getFoodMenuByTitle(@Param("foodTitle") String foodTitle);

    /**
     * 通过年龄id获取百科信息
     * @param ageTagId
     * @return
     */
    @Query("select a from FoodMenu a where a.ageTagId=?1")
    List<FoodMenu> getByAgeId(Long ageTagId);

    /**
     * 通过生病id获取百科信息
     * @param sickTagId
     * @return
     */
    @Query("select a from FoodMenu a where a.sickTagId=?1")
    List<FoodMenu> getBySickId(Long sickTagId);

    /**
     * 通过分类id获取百科信息
     * @param classifyTagId
     * @return
     */
    @Query("select a from FoodMenu a where a.classifyTagId=?1")
    List<FoodMenu> getByClassifyId(Long classifyTagId);


}
